<?php

session_start();

if (isset($_POST['submit'])) {
    $title = $_POST['actTitle'];
    $desc = $_POST['actDesc'];
    $date = $_POST['actDate'];

    include 'DBLibrary/config.php';
    include 'DBLibrary/openDB.php';

    mysql_select_db("rotaract");

    define('FileFolder', 'activityImages/');

    if (isset($_POST['submit'])) {
        $dafile = $_FILES['imageUpload']['name'];
        $target = FileFolder . $dafile;

        move_uploaded_file($_FILES['imageUpload']['tmp_name'], $target);
    }

    $query = "SELECT * FROM activity WHERE title='$title'";
    $result = mysql_query($query);
    $num = mysql_num_rows($result);
    if ($num == 0) {
        $query = "INSERT INTO `rotaract`.`activity` (`title`, `desc`, `date`, `imageurl`) VALUES ('$title', '$desc', '$date', '$target');";
        $result = mysql_query($query);

        $confirm = 'Addition successful!';
    }
}
?>

        <?php

        include 'addActivityUI.php';

        if (isset($confirm)) {
            echo "<br/>";
            echo "<h3>$confirm</h3>";
            echo "<br/>";
        }
        ?>